package com.lhgray.sglhome.presentation.ui.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.lhgray.sglhome.R
import com.lhgray.sglhome.common.utlis.imageloader.ILFactory
import com.lhgray.sglhome.common.utlis.imageloader.ILoader
import com.lhgray.sglhome.domain.model.ImageBean

/**
 * 作者：lhgray on 2025/3/31.
 * 邮箱：lhgray@163.com
 * 文件：com.lhgray.sglhome.screen
 */
class UploadPhotoAdapter() : BaseQuickAdapter<ImageBean, QuickViewHolder>() {

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        // 返回一个 ViewHolder
        return QuickViewHolder(R.layout.bus_item_layout, parent)
    }

    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: ImageBean?) {
        if (item?.imagesType == 0) {
            ILFactory.getLoader().loadNet(
                holder.getView(R.id.shape_imageview),
                item.imagePath,
                ILoader.Options(R.mipmap.bus_ic_sl_image_default, R.mipmap.bus_ic_sl_image_default)
            )
        } else {
            ILFactory.getLoader().loadNet(
                holder.getView(R.id.shape_imageview),
                item?.imageUri,
                ILoader.Options(R.mipmap.bus_ic_sl_image_default, R.mipmap.bus_ic_sl_image_default)
            )
        }
    }

}